#!/bin/bash

# 下载模型
# 检查并下载VAD模型
if [ ! -f "silero_vad.onnx" ]; then
    echo "下载VAD模型..."
    wget https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/silero_vad.onnx
else
    echo "VAD模型已存在，跳过下载"
fi

# 检查并下载ASR模型
if [ ! -d "sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17" ]; then
    echo "下载ASR模型..."
    wget https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17.tar.bz2
    tar xvf sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17.tar.bz2
    rm sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17.tar.bz2
else
    echo "ASR模型已存在，跳过下载"
fi

# 检查并下载TTS模型
if [ ! -d "matcha-icefall-zh-baker" ]; then
    echo "下载TTS模型..."
    wget https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/matcha-icefall-zh-baker.tar.bz2
    tar xvf matcha-icefall-zh-baker.tar.bz2
    rm matcha-icefall-zh-baker.tar.bz2
else
    echo "TTS模型已存在，跳过下载"
fi

# 检查并下载声码器模型
if [ ! -f "vocos-22khz-univ.onnx" ]; then
    echo "下载声码器模型..."
    wget https://github.com/k2-fsa/sherpa-onnx/releases/download/vocoder-models/vocos-22khz-univ.onnx
else
    echo "声码器模型已存在，跳过下载"
fi
